package com.elm.service.impl;

import com.elm.dao.UserDao;
import com.elm.entity.User;
import com.elm.service.UserService;

public class UserServiceImpl implements UserService {
    //引入数据控制层
    private final UserDao userDao;
    public UserServiceImpl() {
        userDao = new UserDao();
    }

    @Override
    public int saveUser(User user) {
        return userDao.saveUser(user);
    }

    @Override
    public int getUserById(String id) {
        return userDao.checkUserExists(id);
    }

    @Override
    public User getUserByIdByPass(String userId, String pas) {
        User user = userDao.getUserByIdAndPassword(userId, pas);
        if (user != null) {user.setPassword(null);}
        return user;
    }
}
